package com.leapp.sk.viewdelegate.album

import android.content.Context
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.text.TextUtils
import android.widget.ListView
import com.example.mvp.delegate.BaseAppDelegate
import com.example.mvp.view.SKTopBar
import com.leapp.sk.R
import com.leapp.sk.bean.AlbumEntity
import com.leapp.sk.ui.activity.classs.ClassAlbumActivity
import com.leapp.sk.ui.adapter.AlbumManagerAdapter

/**
 * 相册管理视图托管类
 * @author  chaohaipeng  on 2018/8/13.
 */
class AlbumManagerDelegate :BaseAppDelegate(){
    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_album_manager
    }
    /**
     * 初始化适配器
     */
    fun initAdapter(context: Context, mlist: List<AlbumEntity>){
        val lv_aam_list = getView<ListView>(R.id.lv_aam_list)
           val mAdapter= AlbumManagerAdapter(context,mlist)
        lv_aam_list.adapter=mAdapter

        lv_aam_list.setOnItemClickListener{adapterView, view, i, l ->
            val intent=Intent(context, ClassAlbumActivity::class.java)
            context.startActivity(intent)

        }

    }
    /**
     * 设置标题
     */
    fun setTitle(title:String?){
        val topBar= getView<SKTopBar>(R.id.jtb_aam_album)
        topBar.inVisibleLine()
        if (!TextUtils.isEmpty(title)){
            topBar?.setTitle(title)
        }
        setEvent(topBar)
    }
    /**
     * 设置设置事件
     */
    private  fun setEvent(topBar: SKTopBar){
        topBar?.setEventInterface(object : SKTopBar.EventInterface{
            override fun leftOnClick() {
                getActivity<AppCompatActivity>().finish()
            }
            override fun rightOnClick() {
            }

        })
    }
    
}